package org.example.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author TonySong
 * @date 2024/6/24 0024
 * @time 10:58
 */
@RestController
@RequestMapping("/service-a")
@Api("测试接口")
public class IndexController {
    @Value("${server.port}")
    private Integer port;

    @GetMapping("/")
    @ApiOperation(tags = "测试get",value = "get")
    public String index() {
        return  this.port+"service-a";
    }

    @PostMapping("/add")
    @ApiOperation("ppost的新增")
    public String index1(User user) {
        System.out.println(user);
        return "添加的对象是："+user;
    }

    @DeleteMapping("/{id}")
    public String delete(@PathVariable("id") Integer id) {
        return "删除的id是："+id;
    }
    @PutMapping("/{id}")
    public String  update(@PathVariable("id") Integer id,User user) {
        System.out.println("........put....."+this.port);
        return "更新的id是："+id+"更新的对象是："+user;
    }
}
